/**
 * 
 */
package com.jolestar.yayaweibotong.service;

import java.util.List;

import com.jolestar.yayaweibotong.ServiceType;
import com.jolestar.yayaweibotong.dao.AbstractDomain;
import com.jolestar.yayaweibotong.dao.AccountDomain;
import com.jolestar.yayaweibotong.dao.InviteTokenDomain;
import com.jolestar.yayaweibotong.dao.StatusDomain;
import com.jolestar.yayaweibotong.dao.UserDomain;
import com.jolestar.yayaweibotong.service.impl.UserServiceImpl;

/**
 * @author jolestar@gmail.com
 * 
 */
public interface UserService {

	UserDomain createUser(String email, String password, String inviteToken);

	UserDomain getDefaultUser();

	List<UserDomain> getUsers(int startIndex, int batchSize);

	List<UserDomain> getNeedSyncUsers(int startIndex,int maxResults);

	List<UserDomain> getActivityUsers(int startIndex,int maxResults);

	UserDomain getUser(String email);

	List<StatusDomain> getUnSyncedStatuses(AccountDomain account, int maxResults);

	/**
	 * 
	 * @param maxResults
	 * @param sinceKeyName
	 *            可以为空
	 * @return
	 */
	List<StatusDomain> getLatestOriginalStatus(int maxResults, String sinceKeyName);

	AccountDomain getAccount(ServiceType serviceType, String originalId);

	AccountDomain getAccount(String keyName);

	void deleteAccount(String keyName);

	boolean validateInviteToken(String inviteToken);

	/**
	 * 已经使用的token
	 * 
	 * @return
	 */
	List<InviteTokenDomain> getUsedTokens();

	void generateInviteToken(int count);

	void sendEmail(String toEmail, String subject, String content);

	void sendEmailToAdmin(String subject, String content);

	/**
	 * 未使用的token
	 * 
	 * @return
	 */
	List<InviteTokenDomain> getUnUsedTokens();

	boolean exists(Class<? extends AbstractDomain> domainClass,
			ServiceType serviceType, String originalId);

	public static class ServiceHolder {
		private static final UserServiceImpl instance = new UserServiceImpl();

		public static UserService getInstance() {
			return instance;
		}
	}

	StatusDomain getStatus(String keyName);

}
